//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Drawing;

namespace OpenLS.Chart
{
    internal class GraphicalObjectFrameNonVisual : IOfficeXmlSerializable
    {
        private NonVisualGraphicFrameProperties _cNvGraphicFramePr;
        private NonVisualDrawingProperties _cNvPr;

        public NonVisualDrawingProperties NonVisualDrawingProperties
        {
            get
            {
                if (_cNvPr == null)
                {
                    _cNvPr = new NonVisualDrawingProperties();
                    _cNvPr.Id = 0; //\\
                    _cNvPr.Name = "Graphical object"; //\\
                }
                return _cNvPr;
            }
            set { _cNvPr = value; }
        }

        public NonVisualGraphicFrameProperties NonVisualGraphicFrameProperties
        {
            get
            {
                if (_cNvGraphicFramePr == null)
                    _cNvGraphicFramePr = new NonVisualGraphicFrameProperties();
                return _cNvGraphicFramePr;
            }
            set { _cNvGraphicFramePr = value; }
        }

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (var c = context.Read("nvGraphicFramePr"))
            {
                _cNvPr = c.ReadElement<NonVisualDrawingProperties>();
                _cNvGraphicFramePr = c.ReadElement<NonVisualGraphicFrameProperties>();
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("nvGraphicFramePr"))
            {
                c.WriteElement(NonVisualDrawingProperties);
                c.WriteElement(NonVisualGraphicFrameProperties);
            }
        }

        #endregion
    }
}